{a^b-b^a}
type
  num = string;
var
  a, b, sign : integer;
  ab, ba, res : num;

function minus(a, b : num) : num;
var
  i, c, nho : longint;
  hieu : num;
begin
  nho := 0;
  hieu := '';
  while length(a) < length(b) do a := '0' + a;
  while length(b) < length(a) do b := '0' + b;
  for i := length(a) downto 1 do
  begin
    c := ord(a[i]) - ord(b[i]) - nho;
    if c < 0 then nho := 1
    else nho := 0;
    c := (c + 10) mod 10;
    hieu := chr(c + 48) + hieu;
  end;
  while (length(hieu) > 1) and (hieu[1] = '0') do delete(hieu, 1, 1);
  minus := hieu;
end;

function mul(a : num; k : byte) : num;
var
  i, c, nho : longint;
  tich : num;
begin
  nho := 0;
  tich := '';
  for i := length(a) downto 1 do
  begin
    c := (ord(a[i]) - 48) * k + nho;
    nho := c div 10;
    c := c mod 10;
    tich := chr(c + 48) + tich;
  end;
  while nho > 0 do
  begin
    tich := chr(nho mod 10 + 48) + tich;
    nho := nho div 10;
  end;
  mul := tich;
end;

procedure cal(a, b : integer; var ab : num);
var
  i : integer;
  temp : num;
begin
  temp := '1';
  for i := 1 to b do temp := mul(temp, a);
  ab := temp;
end;

function lower(a, b : num) : boolean;
begin
  if length(a) < length(b) then
  begin
    lower := true;
    exit;
  end;
  if length(a) > length(b) then
  begin
    lower := false;
    exit;
  end;
  if a < b then lower := true
  else lower := false;
end;

procedure swap(var a, b : num);
var
  temp : num;
begin
  temp := a;
  a := b;
  b := temp;
end;

procedure process;
begin
  cal(a, b, ab);
  cal(b, a, ba);
  sign := 1;
  if lower(ab, ba) then
  begin
    swap(ab, ba);
    sign := -1;
  end;
  res := minus(ab, ba);
end;

begin
  read(a, b);
  process;
  if sign < 0 then write('-');
  writeln(res);
end.